#include "fps_counter.h"
#include "hero.h"
#include "definitions.h"
#include "toolkits/includes/glut.h"

extern float heroVelocity;
extern float fps;

Fps_counter::Fps_counter() {
}

void Fps_counter::fps_calc() {
	static int frame, timebase;
	int time;
	frame++;
	time=glutGet(GLUT_ELAPSED_TIME);
	if (time - timebase > 500) {
		fps = frame*1000.0/(time-timebase);
		heroVelocity = HEROVELOCITY/fps;  
		//printf("FPS:%f\nHero Velocity:%f\n\n",fps,heroVelocity);
		timebase = time;
		frame = 0;
	}
}